﻿using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SimpleMapper;

namespace SimpleMapperTest
{
    [TestClass]
    public class MappingTest
    {
        [TestMethod]
        public void DifferetObjectTypeMappingTest()
        {
            var employee = TestData.GetMockEmployee();
            ObjectMapper<Employee, EmployeeDto> objectMapper = new ObjectMapper<Employee, EmployeeDto>();
            var employeeDto = objectMapper.MapToTarget(employee);
            Assert.IsNotNull(employeeDto);
            Assert.AreEqual(employee.EmployeeId, employeeDto.EmployeeId);
        }

        [TestMethod]
        public void SameObjectTypeMappingTest()
        {
            var employee = TestData.GetMockEmployee();
            ObjectMapper<Employee, Employee> objectMapper = new ObjectMapper<Employee, Employee>();
            var copiedEmployee = objectMapper.MapToTarget(employee);
            Assert.IsNotNull(copiedEmployee);
            Assert.AreEqual(employee.EmployeeId, copiedEmployee.EmployeeId);
        }

        [TestMethod]
        public void DifferetObjectTypeCollectionMappingTest()
        {
            var employees = TestData.GetMockListOfEmployee();
            ObjectMapper<List<Employee>, List<EmployeeDto>> objectMapper = new  ObjectMapper<List<Employee>, List<EmployeeDto>>();
            var employeeDtos = objectMapper.MapToTargetCollection(employees);
            Assert.IsNotNull(employeeDtos);
        }

        [TestMethod]
        public void SameObjectTypeMappingForShallowCopyTest()
        {
            var employee = TestData.GetMockEmployee();
            ObjectMapper<Employee, Employee> objectMapper = new ObjectMapper<Employee, Employee>();
            var mappedEmployee = objectMapper.MapToTarget(employee,true);
            Assert.IsNotNull(mappedEmployee);
            Assert.AreEqual(employee.EmployeeId, mappedEmployee.EmployeeId);
        }
    }
}
